X-Git-Url: https://git.r.bdr.sh/rbdr/super-polarity/blobdiff_plain/8534e46e400268c5ceffb3b14f02cef39eedae8f..3de51c6f55d304f038df1b77c8ab346e2a187fe1:/Super%20Polarity/ScreenManager.cs diff --git a/Super Polarity/ScreenManager.cs b/Super Polarity/ScreenManager.cs new file mode 100644 index 0000000..b88741b --- /dev/null +++ b/Super Polarity/ScreenManager.cs @@ -0,0 +1,55 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Microsoft.Xna.Framework; +using Microsoft.Xna.Framework.Graphics; + +namespace SuperPolarity +{ + static class ScreenManager + { + static Stack Screens; + static SuperPolarity Game; + + static ScreenManager() + { + Screens = new Stack(); + } + + static public void Push(Screen screen) + { + if (Screens.Count > 0) + { + Screens.Peek().Active = false; + } + + screen.LoadContent(); + screen.Active = true; + Screens.Push(screen); + } + + static public void Pop() + { + var screen = Screens.Pop(); + screen.Active = false; + screen.CleanUp(); + Screens.Peek().Active = true; + } + + static public void Update(GameTime gameTime) + { + Screens.Peek().Update(gameTime); + } + + static public void Draw(SpriteBatch spriteBatch) + { + Screens.Peek().Draw(spriteBatch); + } + + internal static void SetGame(SuperPolarity game) + { + Game = game; + } + } +}